package com.lc.big_event.mapper;

import com.lc.big_event.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author liuchun
 */
@Mapper
public interface CategoryMapper {
    /**
     * 新增文章分类
     * @param category
     */
    @Insert("insert into category (category_name, category_alias, create_user, create_time, update_time) VALUES " +
            "(#{categoryName},#{categoryAlias},#{createUser},#{createTime},#{updateTime})")
    void add(Category category);

    /**
     * 文章分类列表
     * @param userId
     * @return
     */
    @Select("select * from category where create_user = #{userId}")
    List<Category> list(Integer userId);

    /**
     * 获取文章分类详情
     * @param id
     * @return
     */
    @Select("select * from category where id = #{id}")
    Category detail(Integer id);

    /**
     * 更新文章分类
     * @param category
     */
    @Update("update category set category_name = #{categoryName},update_time = now(),category_alias = #{categoryAlias} where id = #{id}")
    void updateArticle(Category category);

    /**
     * 删除文章分类
     * @param id
     */
    @Delete("delete from category where id = #{id};")
    void delete(Integer id);
}
